/* isquirrel.js
 * 
 * Description: This script controls the general site behaviour/effects.
 * 
 * iSquirrel
 * 2009
 * Imperial College London
 */
function initPage(){
	
	registerHandlers();
	
}

function registerHandlers(){
	
	$$('input.biginput').each(function(item){
		Event.observe(item, "focus", function(e){
			
			this.setStyle({backgroundColor: "#E3FCDC"});
				
		});
		
		Event.observe(item, "blur", function(e){

			this.setStyle({backgroundColor: "white"});

		});	
		
		Event.observe(item, "keydown", function(e){
			
			if ($("loginbtn") !== null){
				$("loginbtn").setStyle({backgroundPosition: "0px 45px"});
			}
			else {
				$("registerbtn").setStyle({backgroundPosition: "0px 45px"});
			}				
		});
		
		Event.observe(item, "keyup", function(e){

			if ($("loginbtn") !== null){
				$("loginbtn").setStyle({backgroundPosition: "0px 0px"});
			}
			else {
				$("registerbtn").setStyle({backgroundPosition: "0px 0px"});
			}	

		});
		
	});
	
	if ($("loginbtn") !== null){
		
		Event.observe("loginbtn", "mousedown", function(e){
			
			this.setStyle({backgroundPosition: "0px 45px"});
				
		});
		
		Event.observe("loginbtn", "mouseup", function(e){

			this.setStyle({backgroundPosition: "0px 0px"});

		});
		
	}
	
	
	if ($("usr_name") !== null){
		
		$("usr_name").update(usr_name);
		
	}	
}
